;*******************************************************************************
;* Copyright (c) 2009, 2010 SOPERA GmbH
;* All rights reserved.
;* This program and the accompanying materials are made available
;* under the terms of the Eclipse Public License v1.0
;* which accompanies this distribution, and is available at
;* http://www.eclipse.org/legal/epl-v10.html
;*******************************************************************************

;----------------------------------------------------------------------------
;    MODULE NAME:   SOPERAHQ.MM
;----------------------------------------------------------------------------

;--- Define where files are -------------------------------------------------
#define MsiBEFORE_SRC ..\hyperic-hq-installer-4.2.0-win32.msi
#define MsiDestDir    ..\temp\out\Tweek.mm\Msi
#define MsiBEFORE     <$MsiDestDir>\Before.msi
#define MsiAFTER      <$MsiDestDir>\hyperic-hq-installer-4.2.0-win32.msi
#define MsiFINAL      ..\product\hyperic-hq-installer-4.2.0-win32.msi
#define MstFile       <$MsiDestDir>\ConvertBefore2After.mst


;--- Prepare for main actions below --------------------------------------------
#DefineRexx ''
   ;--- Make sure the "source File" exists ---
   if FileQueryExists('<$MsiBEFORE_SRC>') = '' then
      error('The file "<$MsiBEFORE_SRC>" does not exist!');

   ;--- Clean up and prepare a "before" MSI ---------------------------------
   call FileDelete '<$MsiBEFORE>', 'N';
   call FileDelete '<$MsiAFTER>',  'N';
   call MakeDirectoryTree '<$MsiDestDir>';
   call FileCopy   '<$MsiBEFORE_SRC>', '<$MsiBEFORE>';
#DefineRexx


;--- Include the correct support (MAKEMSI.MMH/DEPT.MMH for MSI Creation) ----
#define  COMPILE_CAB_FILE_NAME           TW*        
#define  DBG_ALL                         Y          
#include "OpenMsi.MMH"


<$Msi "<$MsiAFTER>" template="<$MsiBEFORE>">
       <$Feature "Server">                             
            ;--- Create a new component -------------------------------------
            <$Component "AfterUpdatingServerFile" Directory_="INSTALL">
		<$Table "File">
			<$RowsDelete Where=^File='server_4.2.0.tgz'^>
		<$/Table>
		<$Files "..\temp\server-4.2.0.tgz">
		<$Table "File">
			<$Row File="server_4.2.0.tgz" Component_="AllOtherFiles26" FileName="SERVER~1.TGZ|server-4.2.0.tgz" FileSize="84569206" Attributes="16384" Sequence="1">
		<$/Table>
            <$/Component>
       <$/Feature>

;--- Create a transform (can be applied to the "before" msi) -------------
<$Transform "<$MstFile>">
<$/Msi>

#(
   #define+ ONEXIT_AFTER_MSI_BUILT_AND_VALIDATED
   #DefineRexx ''
      call FileCopy '<$MsiAFTER>', '<$MsiFINAL>';
      call FileDelete '<$MsiAFTER>',  'N';
   #DefineRexx
#)